package cn.aitrox.ry.service.config.enumtype;

import org.apache.commons.lang3.StringUtils;

public enum ComponentTypeEnum {
    SELECT("select", "下拉选择框"),
    CHILD_SELECT("child_select", "多层下拉选择框"),
    CHECKBOX("checkbox", "复选框"),
    RADIOBOX("radiobox", "单选框"),
    TEXT("text", "文本框");

    private String  type;

    private String desc;

    ComponentTypeEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }
    public static boolean _isSelect(String type) {
       return SELECT.getType().equalsIgnoreCase(type);
    }

    public static boolean _isCheckbox(String type) {
        return CHECKBOX.getType().equalsIgnoreCase(type);
    }

    public static boolean _isRadiobox(String type) {
        return RADIOBOX.getType().equalsIgnoreCase(type);
    }

    public static boolean _isText(String type) {
        return TEXT.getType().equalsIgnoreCase(type);
    }

    public static ComponentTypeEnum getEnumByType(String type) {
        if(StringUtils.isEmpty(type)) {
            return null;
        }
        for(ComponentTypeEnum componentEnum : ComponentTypeEnum.values()) {
            if(componentEnum.getType().equalsIgnoreCase(type)) {
                return componentEnum;
            }
        }
        return null;
    }
}
